# 1.账户信息源
account_list = [
    {"name":"zhangsan","pw":"123456","money":"10000"},
    {"name":"HU","pw":"456123","money":"10000"},
    {"name":"wangsi","pw":"456123","money":"10000"}
]
#2.登入
def login():
    name_list = []
    pw_list = []
    for account in account_list:
        name_list.append(account["name"])
        pw_list.append(account["pw"])
    name = input("请输入您的账户：")
    pw = input("密码：")
    if str(name) in name_list and str(pw) in pw_list:
        print("欢迎")
        p.append(name_list.index(name))
        return p
    else:
        print("账户或者密码错误，请重新输入")
        login()


#3.查询余额
def check(a):
    name_money = []
    for account in account_list:
        name_money.append(account["money"])
    print("当前余额为：%s元"%name_money[a])

#4.取钱
def carry_money(a):
    name_money = []
    for account in account_list:
        name_money.append(account["money"])
    money =  input("请输入您取款金额")
    money = int(money)
    name_money[a] = int(name_money[a])
    name_money[a] -= money
    print("取款成功，当前余额为：%s元" % int(name_money[a]))

#5.存钱
def add_money(a):
    name_money = []
    for account in account_list:
        name_money.append(account["money"])
    money =  input("请输入您取款金额")
    money = int(money)
    name_money[a] = int(name_money[a])
    name_money[a] += money
    print("存款成功，当前余额为：%s元" % (int(name_money[a])))


#6. 退出
def logout():
    print("谢谢光临")



while True:
    #交互界面
    print("=" * 10, "欢迎光临", "=" * 10)
    print("%s%s%s"%("  ","1.账户登入  ","2.账户查询"))
    print("%s%s%s" % ("  ", "3.取钱  ", "4.存钱"))
    print("%s%s%s" % ("  ", "5.退出", "    "))
    p = []
    choice = input("请选择你的操作：")
    if int(choice) in [1,2,3,4]  :
        login()
        while True:
            #交互界面
            print("%s%s%s" % ("  ", "a.账户查询", "b.取钱  "))
            print("%s%s%s" % ("  ", "c.存钱   ", "d.退出   "))
            a = p[-1]
            choice = input("请选择你的操作：")
            if choice == "a":
                check(a)

            elif choice == "b":
                carry_money(a)

            elif choice == "c":
                add_money(a)

            else:
                logout()
                break
    else:
        logout()
        break
